<template>
	<div>
		<!-- Hotcities热门城市 -->
		<div class="city-hot">
			<div class="hot-title">
				热门城市
			</div>
			<ul class="hot-list">
				<li v-for="(item,index) in hotCities" :key="index" @click="changeCityname(item.name)">
					{{item.name}}
				</li>
			</ul>
		</div>
		<!-- Sort字母排序 -->
		<div class="city-sort">
			<div class="sort-title">
				字母排序
			</div>
			<ul class="sort-list">
				<li v-for="(item,index) in city" :key='index' @click="changeCityname(item.name)">{{item.initial}}</li>
			</ul>
		</div>
		<!-- Lisst城市首字母列表 -->
		<div class="city-list">
			<div v-for="(item,index) in city" :key='index'>
				<div class="list-title">{{item.initial}}</div>
				<ol class="list-item">
					<li v-for="(item,index) in item.list" :key='index'  @click="changeCityname(item.name)">{{item.name}}</li>
				</ol>
			</div>
		</div>
	</div>
</template>

<script>
	import {mapMutations} from 'vuex'
	export default{
		props:['city','hotCities'],
		//绑定Vuex的mutations事件
		methods:{
			changeCityname(cityname){
				this.changeCity(cityname);
				this.$router.push('/')
			},
			...mapMutations(['changeCity'])
		}
	}
</script>

<style scoped>
	.city-list{
		width: 100%;
		font-size: 0.28rem;
	}
	.list-title{
		padding: 0.2rem 0.3rem;
	}
	.list-item{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.list-item:before{
		content: "";
		position: absolute;
		border-left: 1px solid #ddd;
		border-right: 1px solid #ddd;
		width: 25%;
		height: 100%;
		left: 25%;
	}
	.list-item::after{
		content: '';
		position: absolute;
		border-right: 1px solid #ddd;
		width: 0%;/* 解决第三列效果 */
		height: 100%;
		right: 25%;
	}
	.list-item li{
		width: 25%;
		height: 0.9rem;
		/* background-color: burlywood; */
		text-align: center;
		line-height: 0.9rem;
		float: left;
		border-bottom: 0.03rem solid #CCCCCC;
		position: relative;/* 解决第二列效果 */
	}
	/*  */
	.city-hot{
		width: 100%;
		font-size: 0.28rem;
	}
	.hot-title{
		padding: 0.2rem 0.3rem;
	}
	.hot-list{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.hot-list:before{
		content: "";
		position: absolute;
		border-left: 1px solid #ddd;
		border-right: 1px solid #ddd;
		width: 33.333%;
		height: 100%;
		left: 33.333%;
	}
	.hot-list li{
		width: 33.333%;
		height: 0.9rem;
		/* background-color: burlywood; */
		text-align: center;
		line-height: 0.9rem;
		float: left;
		border-bottom: 0.03rem solid #CCCCCC;
		position: relative;
	}
	/*  */
	.city-sort{
		width: 100%;
		font-size: 0.28rem;
	}
	.sort-title{
		padding: 0.2rem 0.3rem;
	}
	.sort-list{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.sort-list li{
		width: 16.666%;
		height: 0.9rem;
		/* background-color: burlywood; */
		text-align: center;
		line-height: 0.9rem;
		float: left;
	}
</style>
